
const searchFormList = [
  { label: '', width: '130px', value: 'btnOperation', type: 'slot' },
	{ label: '关键词', value: 'query', type: 'input', width: '200px' },
  { label: '隶属频道', value: 'channel', type: 'select', width: '200px', option: 'gcPostChannel', filterable: true,  clearable: true},
	{ label: '', width: '200px', value: 'btnSearch', type: 'slot' }
];

const tables = [ // 表格数据
  { label: '记录ID', value: 'id', sort:'custom'},
  { label: '帖子标题', value: 'title'},
  { label: '发帖用户', value: 'user'},
  { label: '关联标签', value: 'ltags'},
  { label: '隶属频道', value: 'channel', type: 'slot'},
  { label: '是否置顶', value: 'istop', type: 'slot'},
  { label: '排序', value: 'rank', width:60},
  { label: '点赞量', value: 'likes', width:70},
  { label: '评论量', value: 'comments', width:70},
  { label: '浏览量', value: 'viewer', width:70},
  { label: '状态', value: 'status', type: 'slot'},
  { label: '发帖时间', value: 'addtime'},
  { label: '更新时间', value: 'stime'}
];

const fieldList = [ // 新增弹出数据
  { label: '标题', value: 'title', type: 'input', width: '460px', className:'block'},
  { label: '隶属频道', value: 'channel', type:'select', width: '200px', option: 'gcPostChannel', filterable: true, className:''},
  { label: '审核状态', value: 'status', type:'select', width: '180px', labelWidth:"80px", option: 'checkStatus', filterable: true, className:''},
  { label: '是否置顶', value: 'istop', type:'select', width: '180px', labelWidth:"80px", option: 'yesOrNo', filterable: true, className:''},
  { label: '排序', value: 'rank', type:'input', width: '180px', labelWidth:"70px", className:''},
  { label: '关联标签', value: 'ntagids', type:'checkbox', attchsField:"tags",  width: '840px', option: 'sysTags', className:''},
  { label: '帖子内容', value: 'content', type:'editor', width: '840px', ueditorStyle:{width:'720px', height:'240px'}, className:''},
];

const rules = {
	title: [{ required: true, message: '请输入标题', trigger: 'change' }],
  channel: [{ required: true, message: '请设置隶属频道', trigger: 'change' }],
	status: [{ required: true, message: '请设置状态', trigger: 'change' }],
  ntagids: [{ required: true, message: '请设置关联标签', trigger: 'change' }],
  content: [{ required: true, message: '请编辑帖子内容', trigger: 'change' }]
};

const fieldData = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldList.length; idx++) {
    var ckey  = fieldList[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  (!dataset['ntagids']) && (dataset['ntagids'] = []);
  (!dataset['otagids']) && (dataset['otagids'] = []);
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  searchFormList,tables,fieldList,fieldData,rules
};